<?php

defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.view');

class admin_employeeModeldashboard extends JModel 
{
    //danh sach nhan vien dang lam viec
    function list_employee()
    {
        $db = &JFactory::getDbo();
        $sql = "
            select us.username, us.name as name_us, pf.*, br.name as name_br, fu.name as name_fu
            from #__users us, #__hc_emplyee_profile pf,#__hc_access ac,#__hc_branch br, #__hc_function fu
            where us.id = pf.id_user 
            and ac.id_user = us.id
            and ac.id_branch = br.id
            and ac.id_function = fu.id
            and pf.deleted=0
        ";
        $db->setQuery($sql);
        return $db->loadObjectList();
    }
    
    //danh sach nhan vien chua co viec\
    function list_employee2()
    {
        $db = &JFactory::getDbo();
        $sql = "
            select us.*
            from #__users us
            where us.id not in(
            select #__users.id
            from #__users, #__hc_emplyee_profile
            where #__users.id = #__hc_emplyee_profile.id_user 
            and #__hc_emplyee_profile.deleted=0
            
            )
            and us.id <> 318
            order by us.name 
        ";
        $db->setQuery($sql);
        return $db->loadObjectList();
    }
    
    //danh sach van phong 
    function list_office()
    {
        $db = &JFactory::getDbo();
        $sql = "select *
            from #__hc_branch
            where #__hc_branch.deleted = 0";
        $db->setQuery($sql);
        return $db->loadObjectList();
    }
    
    //danh sach chuc vu
    function list_function()
    {
        $db = &JFactory::getDbo();
        $sql = "select *
            from #__hc_function
            where #__hc_function.deleted = 0";
        $db->setQuery($sql);
        return $db->loadObjectList();
    }
}
?>

